package tv.dyndns.kishibe.client.ui;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.ui.HTML;

public class RequestedHtml extends HTML {
	public RequestedHtml(String url) {
		final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
		try {
			builder.sendRequest(null, requestCallback);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private final RequestCallback requestCallback = new RequestCallback() {
		public void onResponseReceived(Request request, Response response) {
			setHTML(response.getText());
		}

		public void onError(Request request, Throwable exception) {
			exception.printStackTrace();
		}
	};
}
